package dice.sinanya.db.properties.system;

import dice.sinanya.db.tools.DbUtil;
import dice.sinanya.entity.EntitySystemProperties;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import static dice.sinanya.system.MessagesSystem.loginInfo;

/**
 * @author SitaNya
 * 日期: 2019-06-15
 * 电子邮箱: sitanya@qq.com
 * 维护群(QQ): 162279609
 * 有任何问题欢迎咨询
 * 类说明: 录入KP主群类
 */
public class InsertProperties {
    private static final Logger log = LogManager.getLogger(InsertProperties.class.getName());

    public void insertProperties(EntitySystemProperties entitySystemProperties) {
        try (Connection conn = DbUtil.getConnection()) {
            //language=MySQL
            String sql = "replace into  test.systemProperties(botId," +
                    "botStart," +
                    "botAlreadyStart," +
                    "botStop," +
                    "botAlreadyStop," +
                    "botExit," +
                    "botInfo," +
                    "bookCard," +
                    "bookRp," +
                    "bookKp," +
                    "bookMake," +
                    "manyRollsFormat," +
                    "diceTimesTooBig," +
                    "setPropFormat," +
                    "setHelp," +
                    "NotFoundSkill," +
                    "setPropSuccess," +
                    "dndInitIsEmtpy," +
                    "clrDndInit," +
                    "needKpGroup," +
                    "cantInPrivate," +
                    "onlyManager," +
                    "alreadyOpen," +
                    "alreadyClose," +
                    "notFoundLog," +
                    "readLock," +
                    "deleteOpenLog," +
                    "sanCheck," +
                    "antagonizeOver," +
                    "antagonizeFirstSuccess," +
                    "antagonizeSecondSuccess," +
                    "antagonizeAllFailed," +
                    "antagonizeDraw," +
                    "symptom," +
                    "enSuccess," +
                    "enFailed," +
                    "hiddenDice," +
                    "teamIsEmpty," +
                    "teamMemberEnIsEmpty," +
                    "appendLog," +
                    "createLog," +
                    "CantEmptyLogName," +
                    "sanCheckFumble," +
                    "sanCheckCriticalSuccess," +
                    "sanCheckSuccess," +
                    "sanCheckFailure," +
                    "CRITICAL_SUCCESS," +
                    "EXTREME_SUCCESS," +
                    "HARD_SUCCESS," +
                    "SUCCESS," +
                    "FAILURE," +
                    "FUMBLE,public,running,helpInfo,zookeeper,rollInfo,autoUpdate,customSearchUpdate,customSearchInsert,deckListShow,diceListShow,clueInsert,clueRemove,clueClear,setKp,monsterSet,monsterNeedKp,monsterSetDone,monsterFormatError,monsterClear,monsterClearDone,monsterShow,noticeInsert,noticeEmpty,noticeShow,noticeAgree,noticeNotFound,noticeRefuse,npcInsertForKp,npcNeedKp,npcInsert,npcFormatError,npcDelete,npcClear,npcShow,roleAlreadyLock,roleTooLong,roleDefault,roleUpdate,roleChange,roleShow,roleCantDelete,roleCantDeleteByLock,roleDelete,roleChangeDefault,roleLock,roleLockDone,roleUnlock,roleNotLock,roleChangeName,roleNotChoose,sendMustInsert,sendAlready,answerFormatError,diceDefault,diceFormat,teamFormatError,teamInsert,teamRemove,teamClear,teamCall,teamNotChooseRole,teamShow,teamProp,teamDesc,teamEn,teamRename,teamLock,teamLockChange,rbStr,rpStr,riStr,initStr,initRm,initSet,rResult,rhStr,rhForSkill,historyStr,logOffDone,logGetForOpen,manNotFound,dndQKError,makeCardTooMore,cnModError,cnModNumberZero,cnModPageNumTooBig,customAlreadyExist,customFormat,fireAlreadyInPage,fireRd,fireSkill,getNameTimes,getNameTimesTooMore,initSetFormat,inputNameTimesForNumber,notAdminPower,notEnableBySimple,notEnable,notEnableInGroup,notFoundGroup,rollCantInZero,setAlgorithmType,setRuleFormat,wodCheckMaxCantInA,wodCheckNotIsOne,wodToMore)  VALUES (?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?," +
                    "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
            try (PreparedStatement ps = conn.prepareStatement(sql)) {

                ps.setString(1, String.valueOf(loginInfo.getLoginId()));
                ps.setString(2, entitySystemProperties.getBotStart("0"));
                ps.setString(3, entitySystemProperties.getBotAlreadyStart("0"));
                ps.setString(4, entitySystemProperties.getBotStop("0"));
                ps.setString(5, entitySystemProperties.getBotAlreadyStop("0"));
                ps.setString(6, entitySystemProperties.getBotExit("0"));
                ps.setString(7, entitySystemProperties.getBotInfo("0"));
                ps.setString(8, entitySystemProperties.getBookCard("0"));
                ps.setString(9, entitySystemProperties.getBookRp("0"));
                ps.setString(10, entitySystemProperties.getBookKp("0"));
                ps.setString(11, entitySystemProperties.getBookMake("0"));
                ps.setString(12, entitySystemProperties.getManyRollsFormat("0"));
                ps.setString(13, entitySystemProperties.getDiceTimesTooBig("0"));
                ps.setString(14, entitySystemProperties.getSetPropFormat("0"));
                ps.setString(15, entitySystemProperties.getSetHelp("0"));
                ps.setString(16, entitySystemProperties.getNotFoundSkill("0"));
                ps.setString(17, entitySystemProperties.getSetPropSuccess("0"));
                ps.setString(18, entitySystemProperties.getDndInitIsEmtpy("0"));
                ps.setString(19, entitySystemProperties.getClrDndInit("0"));
                ps.setString(20, entitySystemProperties.getNeedKpGroup("0"));
                ps.setString(21, entitySystemProperties.getCantInPrivate("0"));
                ps.setString(22, entitySystemProperties.getOnlyManager("0"));
                ps.setString(23, entitySystemProperties.getAlreadyOpen("0"));
                ps.setString(24, entitySystemProperties.getAlreadyClose("0"));
                ps.setString(25, entitySystemProperties.getNotFoundLog("0"));
                ps.setString(26, entitySystemProperties.getReadLock("0"));
                ps.setString(27, entitySystemProperties.getDeleteOpenLog("0"));
                ps.setString(28, entitySystemProperties.getSanCheck("0"));
                ps.setString(29, entitySystemProperties.getAntagonizeOver("0"));
                ps.setString(30, entitySystemProperties.getAntagonizeFirstSuccess("0"));
                ps.setString(31, entitySystemProperties.getAntagonizeSecondSuccess("0"));
                ps.setString(32, entitySystemProperties.getAntagonizeAllFailed("0"));
                ps.setString(33, entitySystemProperties.getAntagonizeDraw("0"));
                ps.setString(34, entitySystemProperties.getSymptom("0"));
                ps.setString(35, entitySystemProperties.getEnSuccess("0"));
                ps.setString(36, entitySystemProperties.getEnFailed("0"));
                ps.setString(37, entitySystemProperties.getHiddenDice("0"));
                ps.setString(38, entitySystemProperties.getTeamIsEmpty("0"));
                ps.setString(39, entitySystemProperties.getTeamMemberEnIsEmpty("0"));
                ps.setString(40, entitySystemProperties.getAppendLog("0"));
                ps.setString(41, entitySystemProperties.getCreateLog("0"));
                ps.setString(42, entitySystemProperties.getCantEmptyLogName("0"));
                ps.setString(43, entitySystemProperties.getSanCheckFumble("0"));
                ps.setString(44, entitySystemProperties.getSanCheckCriticalSuccess("0"));
                ps.setString(45, entitySystemProperties.getSanCheckSuccess("0"));
                ps.setString(46, entitySystemProperties.getSanCheckFailure("0"));
                ps.setString(47, entitySystemProperties.getCRITICAL_SUCCESS("0"));
                ps.setString(48, entitySystemProperties.getEXTREME_SUCCESS("0"));
                ps.setString(49, entitySystemProperties.getHARD_SUCCESS("0"));
                ps.setString(50, entitySystemProperties.getSUCCESS("0"));
                ps.setString(51, entitySystemProperties.getFAILURE("0"));
                ps.setString(52, entitySystemProperties.getFUMBLE("0"));
                ps.setBoolean(53, entitySystemProperties.isPublicMode());
                ps.setBoolean(54, entitySystemProperties.isRunning());
                ps.setString(55, entitySystemProperties.getHelpInfo("0"));
                ps.setBoolean(56, entitySystemProperties.isZookeeper());
                ps.setString(57, entitySystemProperties.getRollInfo("0"));
                ps.setBoolean(58, entitySystemProperties.isAutoUpdate());
                ps.setString(59, entitySystemProperties.getCustomSearchUpdate("0"));
                ps.setString(60, entitySystemProperties.getCustomSearchInsert("0"));
                ps.setString(61, entitySystemProperties.getDeckListShow("0"));
                ps.setString(62, entitySystemProperties.getDiceListShow("0"));
                ps.setString(63, entitySystemProperties.getClueInsert("0"));
                ps.setString(64, entitySystemProperties.getClueRemove("0"));
                ps.setString(65, entitySystemProperties.getClueClear("0"));
                ps.setString(66, entitySystemProperties.getSetKp("0"));
                ps.setString(67, entitySystemProperties.getMonsterSet("0"));
                ps.setString(68, entitySystemProperties.getMonsterNeedKp("0"));
                ps.setString(69, entitySystemProperties.getMonsterSetDone("0"));
                ps.setString(70, entitySystemProperties.getMonsterFormatError("0"));
                ps.setString(71, entitySystemProperties.getMonsterClear("0"));
                ps.setString(72, entitySystemProperties.getMonsterClearDone("0"));
                ps.setString(73, entitySystemProperties.getMonsterShow("0"));
                ps.setString(74, entitySystemProperties.getNoticeInsert("0"));
                ps.setString(75, entitySystemProperties.getNoticeEmpty("0"));
                ps.setString(76, entitySystemProperties.getNoticeShow("0"));
                ps.setString(77, entitySystemProperties.getNoticeAgree("0"));
                ps.setString(78, entitySystemProperties.getNoticeNotFound("0"));
                ps.setString(79, entitySystemProperties.getNoticeRefuse("0"));
                ps.setString(80, entitySystemProperties.getNpcInsertForKp("0"));
                ps.setString(81, entitySystemProperties.getNpcNeedKp("0"));
                ps.setString(82, entitySystemProperties.getNpcInsert("0"));
                ps.setString(83, entitySystemProperties.getNpcFormatError("0"));
                ps.setString(84, entitySystemProperties.getNpcDelete("0"));
                ps.setString(85, entitySystemProperties.getNpcClear("0"));
                ps.setString(86, entitySystemProperties.getNpcShow("0"));
                ps.setString(87, entitySystemProperties.getRoleAlreadyLock("0"));
                ps.setString(88, entitySystemProperties.getRoleTooLong("0"));
                ps.setString(89, entitySystemProperties.getRoleDefault("0"));
                ps.setString(90, entitySystemProperties.getRoleUpdate("0"));
                ps.setString(91, entitySystemProperties.getRoleChange("0"));
                ps.setString(92, entitySystemProperties.getRoleShow("0"));
                ps.setString(93, entitySystemProperties.getRoleCantDelete("0"));
                ps.setString(94, entitySystemProperties.getRoleCantDeleteByLock("0"));
                ps.setString(95, entitySystemProperties.getRoleDelete("0"));
                ps.setString(96, entitySystemProperties.getRoleChangeDefault("0"));
                ps.setString(97, entitySystemProperties.getRoleLock("0"));
                ps.setString(98, entitySystemProperties.getRoleLockDone("0"));
                ps.setString(99, entitySystemProperties.getRoleUnlock("0"));
                ps.setString(100, entitySystemProperties.getRoleNotLock("0"));
                ps.setString(101, entitySystemProperties.getRoleChangeName("0"));
                ps.setString(102, entitySystemProperties.getRoleNotChoose("0"));
                ps.setString(103, entitySystemProperties.getSendMustInsert("0"));
                ps.setString(104, entitySystemProperties.getSendAlready("0"));
                ps.setString(105, entitySystemProperties.getAnswerFormatError("0"));
                ps.setString(106, entitySystemProperties.getDiceDefault("0"));
                ps.setString(107, entitySystemProperties.getDiceFormat("0"));
                ps.setString(108, entitySystemProperties.getTeamFormatError("0"));
                ps.setString(109, entitySystemProperties.getTeamInsert("0"));
                ps.setString(110, entitySystemProperties.getTeamRemove("0"));
                ps.setString(111, entitySystemProperties.getTeamClear("0"));
                ps.setString(112, entitySystemProperties.getTeamCall("0"));
                ps.setString(113, entitySystemProperties.getTeamNotChooseRole("0"));
                ps.setString(114, entitySystemProperties.getTeamShow("0"));
                ps.setString(115, entitySystemProperties.getTeamProp("0"));
                ps.setString(116, entitySystemProperties.getTeamDesc("0"));
                ps.setString(117, entitySystemProperties.getTeamEn("0"));
                ps.setString(118, entitySystemProperties.getTeamRename("0"));
                ps.setString(119, entitySystemProperties.getTeamLock("0"));
                ps.setString(120, entitySystemProperties.getTeamLockChange("0"));
                ps.setString(121, entitySystemProperties.getRbStr("0"));
                ps.setString(122, entitySystemProperties.getRpStr("0"));
                ps.setString(123, entitySystemProperties.getRiStr("0"));
                ps.setString(124, entitySystemProperties.getInitStr("0"));
                ps.setString(125, entitySystemProperties.getInitRm("0"));
                ps.setString(126, entitySystemProperties.getInitSet("0"));
                ps.setString(127, entitySystemProperties.getrResult("0"));
                ps.setString(128, entitySystemProperties.getRhStr("0"));
                ps.setString(129, entitySystemProperties.getRhForSkill("0"));
                ps.setString(130, entitySystemProperties.getHistoryStr("0"));
                ps.setString(131, entitySystemProperties.getLogOffDone("0"));
                ps.setString(132, entitySystemProperties.getLogGetForOpen("0"));
                ps.setString(133, entitySystemProperties.getManNotFound("0"));
                ps.setString(134, entitySystemProperties.getDndQKError("0"));
                ps.setString(135, entitySystemProperties.getMakeCardTooMore("0"));
                ps.setString(136, entitySystemProperties.getCnModError("0"));
                ps.setString(137, entitySystemProperties.getCnModNumberZero("0"));
                ps.setString(138, entitySystemProperties.getCnModPageNumTooBig("0"));
                ps.setString(139, entitySystemProperties.getCustomAlreadyExist("0"));
                ps.setString(140, entitySystemProperties.getCustomFormat("0"));
                ps.setString(141, entitySystemProperties.getFireAlreadyInPage("0"));
                ps.setString(142, entitySystemProperties.getFireRd("0"));
                ps.setString(143, entitySystemProperties.getFireSkill("0"));
                ps.setString(144, entitySystemProperties.getGetNameTimes("0"));
                ps.setString(145, entitySystemProperties.getGetNameTimesTooMore("0"));
                ps.setString(146, entitySystemProperties.getInitSetFormat("0"));
                ps.setString(147, entitySystemProperties.getInputNameTimesForNumber("0"));
                ps.setString(148, entitySystemProperties.getNotAdminPower("0"));
                ps.setString(149, entitySystemProperties.getNotEnableBySimple("0"));
                ps.setString(150, entitySystemProperties.getNotEnable("0"));
                ps.setString(151, entitySystemProperties.getNotEnableInGroup("0"));
                ps.setString(152, entitySystemProperties.getNotFoundGroup("0"));
                ps.setString(153, entitySystemProperties.getRollCantInZero("0"));
                ps.setString(154, entitySystemProperties.getSetAlgorithmType("0"));
                ps.setString(155, entitySystemProperties.getSetRuleFormat("0"));
                ps.setString(156, entitySystemProperties.getWodCheckMaxCantInA("0"));
                ps.setString(157, entitySystemProperties.getWodCheckNotIsOne("0"));
                ps.setString(158, entitySystemProperties.getWodToMore("0"));
                ps.executeUpdate();
            }
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
        }
    }
}